import { reqAddHospitalSet } from '@/api/hospital/hospitalSet'
import { ReqAddHospitalSetParams } from '@/api/hospital/hospitalSet/types'
import { Button, Form, Input, Space, message } from 'antd'
import React from 'react'
import { useNavigate } from 'react-router-dom'

export default function AddORUpdataHospital() {
  let onFinish = async (valuse: ReqAddHospitalSetParams) => {
    await reqAddHospitalSet(valuse);
    message.success('新增成功');
    navigate('/syt/hospital/hospitalSet')
  }
  let onFinishFailed = () => { }
  // 获得nacigata
  let navigate = useNavigate();
  // 返回页面
  let back = () => {
    navigate(-1)
  }
  return (
    <Form
      name="basic"
      labelCol={{ span: 2 }}
      wrapperCol={{ span: 16 }}
      initialValues={{ remember: true }}
      onFinish={onFinish}
      onFinishFailed={onFinishFailed}
      autoComplete="off"
    >
      <Form.Item
        label="医院名称"
        name="hosname"
        rules={[{ required: true, message: '医院名称不能为空' }]}
      >
        <Input />
      </Form.Item>

      <Form.Item
        label="医院编号"
        name="hoscode"
        rules={[{ required: true, message: '医院编号不能为空!' }]}
      >
        <Input />
      </Form.Item>
      <Form.Item
        label="api基础设置"
        name="apiUrl"
        rules={[{ required: true, message: 'api基础设置不能为空!' }]}
      >
        <Input />
      </Form.Item>
      <Form.Item
        label="联系人姓名"
        name="contactsName"
        rules={[{ required: true, message: '联系人姓名不能为空!' }]}
      >
        <Input />
      </Form.Item>
      <Form.Item
        label="联系人电话"
        name="contactsPhone"
        rules={[{ required: true, message: '联系人电话不能为空!' },
        { pattern: /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[1589]))\d{8}$/, message: '请输入正确的手机号' }]}
      >
        <Input />
      </Form.Item>



      <Form.Item wrapperCol={{ offset: 2, span: 22 }}>
        <Space>
          <Button type="primary" htmlType="submit">
            保存
          </Button>
          <Button onClick={back}>返回</Button>
        </Space>
      </Form.Item>
    </Form>
  )
}
